# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import logging
import horovod.torch as hvd

logger = logging.getLogger()

strhdlr = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s [%(filename)s:%(lineno)d] %(levelname)s %(message)s')
strhdlr.setFormatter(formatter)

logger.setLevel(logging.INFO)
logger.addHandler(strhdlr)

def add_log_file(logfile):
    local_logfile = "rank%d-%s" % (hvd.rank(), logfile)
    hdlr = logging.FileHandler(local_logfile)
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr) 
